package com.wkhyapp.lm.contract;

import com.wkhyapp.lm.base.BasePresenter;
import com.wkhyapp.lm.http.ApiCallback;
import com.wkhyapp.lm.http.net.FansListRequest;
import com.wkhyapp.lm.http.net.GoodsInfoRequest;
import com.wkhyapp.lm.http.net.SuperResponse;
import com.wkhyapp.lm.http.vo.Goods;
import com.wkhyapp.lm.utils.MemberUtils;

/**
 * Created by Administrator on 2021-10-6.
 */

public class GoodsPresenter extends BasePresenter<GoodsView> {


    public GoodsPresenter(GoodsView goodsView) {
        super(goodsView);
    }

    public void getData(Long goodsId){
        GoodsInfoRequest request = new GoodsInfoRequest();
        request.setUserId(MemberUtils.getUid());
        request.setGoodsId(goodsId);
        addSubscription(apiStores.goodsInfo(request),new ApiCallback<SuperResponse<Goods>>() {
            @Override
            public void onSuccess(SuperResponse<Goods> response) {
                mvpView.setGoods(response.getItem());
            }
            @Override
            public void onFailure(String msg) {
            }

            @Override
            public void onFinish() {
                mvpView.dismissLoad();
            }
        });
    }


    public void gz(Long goodsId){
        GoodsInfoRequest request = new GoodsInfoRequest();
        request.setUserId(MemberUtils.getUid());
        request.setGoodsId(goodsId);
        addSubscription(apiStores.followGoods(request),new ApiCallback<SuperResponse<String>>() {
            @Override
            public void onSuccess(SuperResponse<String> response) {
                mvpView.setSucc(response.getMessage());
            }
            @Override
            public void onFailure(String msg) {
            }

            @Override
            public void onFinish() {
                mvpView.dismissLoad();
            }
        });
    }
}
